<div class="row justify-content-center">
    <div class="col-8">
        <form (ngSubmit)="save()" [formGroup]="editForm" name="editForm" novalidate role="form">
            <h2 id="jhi-bank-account-heading"
                jhiTranslate="jhipsterSampleApplicationApp.bankAccount.home.createOrEditLabel">Create or edit a Bank
                Account</h2>

            <div>
                <jhi-alert-error></jhi-alert-error>

                <div [hidden]="!editForm.get('id')!.value" class="form-group">
                    <label for="id" jhiTranslate="global.field.id">ID</label>
                    <input class="form-control" formControlName="id" id="id" name="id" readonly type="text"/>
                </div>

                <div class="form-group">
                    <label class="form-control-label" for="field_name"
                           jhiTranslate="jhipsterSampleApplicationApp.bankAccount.name">Name</label>
                    <input class="form-control" formControlName="name" id="field_name" name="name"
                           type="text"/>
                    <div *ngIf="editForm.get('name')!.invalid && (editForm.get('name')!.dirty || editForm.get('name')!.touched)">
                        <small *ngIf="editForm.get('name')?.errors?.required"
                               class="form-text text-danger" jhiTranslate="entity.validation.required">
                            This field is required.
                        </small>
                    </div>
                </div>

                <div class="form-group">
                    <label class="form-control-label" for="field_balance"
                           jhiTranslate="jhipsterSampleApplicationApp.bankAccount.balance">Balance</label>
                    <input class="form-control" formControlName="balance" id="field_balance" name="balance"
                           type="number"/>
                    <div *ngIf="editForm.get('balance')!.invalid && (editForm.get('balance')!.dirty || editForm.get('balance')!.touched)">
                        <small *ngIf="editForm.get('balance')?.errors?.required"
                               class="form-text text-danger" jhiTranslate="entity.validation.required">
                            This field is required.
                        </small>
                        <small [hidden]="!editForm.get('balance')?.errors?.number"
                               class="form-text text-danger" jhiTranslate="entity.validation.number">
                            This field should be a number.
                        </small>
                    </div>
                </div>

                <div class="form-group">
                    <label class="form-control-label" for="field_user"
                           jhiTranslate="jhipsterSampleApplicationApp.bankAccount.user">User</label>
                    <select class="form-control" formControlName="user" id="field_user" name="user">
                        <option [ngValue]="null"></option>
                        <option *ngFor="let userOption of users; trackBy: trackById"
                                [ngValue]="userOption.id === editForm.get('user')!.value?.id ? editForm.get('user')!.value : userOption">
                            {{ userOption.login }}
                        </option>
                    </select>
                </div>
            </div>

            <div>
                <button (click)="previousState()" class="btn btn-secondary" id="cancel-save" type="button">
                    <fa-icon icon="ban"></fa-icon>&nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span>
                </button>

                <button [disabled]="editForm.invalid || isSaving" class="btn btn-primary" id="save-entity"
                        type="submit">
                    <fa-icon icon="save"></fa-icon>&nbsp;<span jhiTranslate="entity.action.save">Save</span>
                </button>
            </div>
        </form>
    </div>
</div>
